/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.server;

import com.ps.server.classes.languages;
import com.ps.server.classes.manufacturers;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author Ricardo
 */
public class operacion {

    public static final String Languages = "languages";
    public static final String Products = "products";
    public static final String Manufacturer = "manufacturers";
    private languages clslang;
    private Vector FullData;
    private Hashtable datHas;

    public operacion() {

        clslang = new languages();
    }

    public Vector Data() {

        return this.FullData;
    }

    public Hashtable dataHas() {
        return datHas;
    }

    public manufacturers getManufacturer(int index) {
        return (manufacturers) this.FullData.get(index);
    }

    public void Post(manufacturers manufact) {
        ClientRest cr = new ClientRest();
        cr.ejecutarMetodoPost(this.Manufacturer, manufact.toXML(), "text/xml", "UTF-8");
    }

    public void Put(manufacturers manufact) {
        ClientRest cr = new ClientRest();
        cr.ejecutarMetodoPut(this.Manufacturer, manufact.toXML(), "text/xml", "UTF-8");


        //this.FullData.set(Integer.valueOf(lang.getId()), cr.getGetVector().get(0)); 

    }

    public languages getLanguage(int index) {
        return (languages) this.FullData.get(index);
    }

    public void Post(languages lang) {
        ClientRest cr = new ClientRest();
        cr.ejecutarMetodoPost(this.Languages, lang.toXML(), "text/xml", "UTF-8");
    }

    public void GetAll(String resource) {
        //if (resource.equals("languages")) {
        ClientRest cr = new ClientRest();

        cr.ejecutarMetodoGet(resource, "?display=full");
        if (resource.equals("configurations")) {
            datHas = cr.getconfig();
        } else {
            this.FullData = cr.getVector();
        }

        //}
    }

    public void Put(languages lang) {
        ClientRest cr = new ClientRest();
        cr.ejecutarMetodoPut(this.Languages, lang.toXML(), "text/xml", "UTF-8");


        //this.FullData.set(Integer.valueOf(lang.getId()), cr.getGetVector().get(0)); 

    }
//    public void Post(clsCategory category) {
//        this.FullData.add(category);
//        EnviarDataWebXml(category.toXML());
//    }
}